<template>
    <div class="login">
        <el-space style="float:right ;width:350px;height:550px;">
            <el-card>
                <template #header>
                    <el-space>
                        <img src="icon1.ico" />
                        <scan>E企查后台管理系统登录界面</scan>
                    </el-space>

                </template>
                <el-input v-model="user.account" class="account" placeholder="请输入账号"> <template #prepend>
                        <el-icon>
                            <User />
                        </el-icon>
                    </template>
                </el-input>
                <el-input v-model="user.password" class="password" type="password" placeholder="请输入密码" show-password>
                    <template #prepend>
                        <el-icon>
                            <Unlock />
                        </el-icon>
                    </template>
                </el-input>
                <el-button type="primary" style=" float: right;margin: 10px;" @click="handleLogin()">登录
                </el-button>
            </el-card>
        </el-space>
    </div>
</template>

<style>
.login {
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-image: url('https://s1.328888.xyz/2022/09/23/IXwzF.jpg');
}

.password {
    margin-top: 10px;
}
</style>

<script>
import { Login } from '../api/post/login'
export default {
    data() {
        return {
            user: {
                account: '',
                password: ''
            }
        }
    }, methods: {
        handleLogin() {
            Login(this.user.account, this.user.password).then((res) => {
                console.log(res)
                if (res.data.code == 200 && res.data.token.isLogin == true) {
                    this.$store.commit('setUser', res.data.user)
                    this.$store.commit('setToken', res.data.token)
                    this.$store.dispatch("getIndex")
                    this.$router.push('/index')
                }

            })
        }
    }
}

</script>